package com.liang.frpdemo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Action1;

public class MainActivity extends Activity implements OnClickListener {

	/*用户输入完地址点击提交按钮---调用反地理编码功能获取经纬度(asyn)---将经纬度提交后台服务器(asyn)*/

    private EditText address;
    private Button commit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        address = (EditText) findViewById(R.id.et_address);
        commit = (Button) findViewById(R.id.btn_commit);

        commit.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_commit://点击提交
//			LocationHelper.getHelper().commit(address.getText().toString()).start(new CallBack<Void>() {
//
//				@Override
//				public void onResult(Void result) {
//					LogUtils.e("Main onResult");
//				}
//
//				@Override
//				public void onError() {
//					LogUtils.e("Main onError");
//				}
//			});
                NewLocationHelper.getHelper().commit(address.getText().toString()).subscribe(
                        new Action1<Void>() {
                            @Override
                            public void call(Void aVoid) {
                                LogUtils.e("onNext");
                            }
                        },
                        new Action1<Throwable>() {
                            @Override
                            public void call(Throwable throwable) {
                                LogUtils.e("onError");
                            }
                        },
                        new Action0() {
                            @Override
                            public void call() {
                                LogUtils.e("onFinish");
                            }
                        }
                );
                break;
        }
    }

}
